<?php



class Modalidad
{
	var $id;
	
	var $nombre;
	
	var $tabla = 'modalidades';

	var $structure = array(
						'id'	=> '0',
						'nombre'=> 'nombre',
					);

	function index($where=null){

		$datos = new Datos();
		
		$datos->conectar();
		
		$query = "SELECT ";
		
		$query2 = " FROM " . $this->tabla;
		
		foreach($this->structure as $k=>$v){
		
			$query .=  $k . ",";
									
		}
				
		$query = substr($query, 0, strlen($query)-1);
		
		if(!empty($where)){
			
			foreach($where as $k=>$v){
			
				$query2 .= $k  . "='" . $v . "' AND";
						
			}
			$query .= " WHERE " . substr($query2, 0, strlen($query2)-3);
		}
		
		$query .= $query2 . ";";
		
		@mysql_query("SET NAMES 'utf8'");
		
		$data = mysql_db_query($datos->database, $query);
		
		$modalidades = array();
		
		while($i = mysql_fetch_array($data)) {
		
			$tmp = array(
						'id'			=> $i['id'],
						'nombre'		=> $i['nombre']
					);
			$modalidades[] = $tmp;

		}
				
		$datos->desconectar();
		
		return $modalidades;		
	}						
}

?>